package com.moyun.finance.controller;

import com.moyun.finance.entity.*;
import com.moyun.finance.service.AccountService;
import com.moyun.finance.service.OrgDeptUserMidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/org/deptUserMid")
public class OrgDeptUserMidController {
    @Autowired
    OrgDeptUserMidService odumsv;

    //批量新增部门下用户
    @RequestMapping("/save")
    public @ResponseBody Response save(@RequestBody List<OrgDeptUserMid> odums){
        Response res = odumsv.save(odums);
        return res;
    }

//    @RequestMapping("/update")
//    public @ResponseBody Response update(@RequestBody List<OrgDeptUserMid> odums){
//        Response res = odumsv.update(odums);
//        return res;
//    }

    //从部门中删除
    @RequestMapping("/delete")
    public @ResponseBody Response delete(@RequestBody OrgDeptUserMid odum){
        Response res = odumsv.delete(odum);
        return res;
    }

    //根据部门查用户
    @RequestMapping("/findAllUserByDept")
    public @ResponseBody Response findAllUserByDept(String deptId){
        List<OrgUser> users = odumsv.findAllUserByDept(deptId);
        return new Response("",users,true);
    }

    //根据用户id查部门
    @RequestMapping("/findUserDeptByUser")
    public @ResponseBody Response findUserDeptByUser(String userId){
        List<OrgDept> depts = odumsv.findUserDeptByUser(userId);
        return new Response("",depts,true);
    }
}
